<?php
namespace Admin\Controller;
use Think\Controller;
/*
后台分类管理  
 */
class 	CategoryController extends CommonController {
	//模板
	public function category()
	{

		//取子父类分类
   		$cate = M('category')->select();
   		// var_dump($cate);
   		$this->assign('cates',$cate);

   		$tempArr=[];
   		foreach ($cate as $row) {
   			if ($row['fid']==0) {
   				$tempArr[$row['id']]=$row;
   			}
   		}
   		// var_dump($tempArr[$row['id']]);
   		foreach ($cate as $son) {
   			foreach ($tempArr as $key => $fater) {
   				if ($son['fid']==$key) {
   					$tempArr[$key]['son'][]=$son;
   				}
   			}
   		}
   		// var_dump($tempArr[$key]['son']);
   		$this->assign('cate',$tempArr);
		// var_dump($tempArr);
		$this->display();
	}







}
?>